//
//  NetworkTools.swift
//  CWLiving
//
//  Created by 方正刚 on 2017/7/5.
//  Copyright © 2017年 方正刚. All rights reserved.
//

import UIKit
import Alamofire

enum RequesType {
    case GET
    case POST
}

class NetworkTools {
    
    class func requestData(type: RequesType, URLSrting: String, parameters: [String : Any]? = nil, finishedBack: @escaping (_ result: Any) -> ()) {
        
        // let 获取类型
        let method = type == .GET ? HTTPMethod.get : HTTPMethod.post
        
        Alamofire.request(URLSrting, method: method, parameters: parameters).responseJSON { (respose) in
            
            guard let result = respose.result.value else {
            
                print(respose.result.error!)
                return
            }
            
            finishedBack(result)
            
        }
        
    }
    
}
